package com.suarte.core;
import com.suarte.utils.Persistent;
import org.appfuse.model.BaseObject;

import javax.persistence.*;
import org.appfuse.model.User;

/**
 * Created by IntelliJ IDEA.
 * User: Gcastillo
 * Date: Dec 30, 2010
 * Time: 5:05:40 PM
 * To change this template use File | Settings | File Templates.
 */

@Entity @Table(name = "sa_employees")
public class Employee extends BaseObject implements Persistent{
    private Long id;
    private String firstName;
    private String middleName;
    private String lastName;
    private String address;
    private String homePhone;
    private String mobilePhone;
    private String otherPhone;
    private EmployeeType type;
    private String career;
    private String occupation;
    private String email;
    private Boolean active;
    private User user;
    private Long oldId;

    public Employee(){
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EMPLOYEE_SEQ")
    @SequenceGenerator(name = "EMPLOYEE_SEQ", sequenceName = "EMPLOYEE_SEQ", allocationSize = 1)
    public Long getId() {
        return id;
    }

    @Column (name = "first_name")
    public String getFirstName() {
        return firstName;
    }

    @Column (name = "middle_name")
    public String getMiddleName() {
        return middleName;
    }

    @Column (name = "last_name")
    public String getLastName() {
        return lastName;
    }

    @Column (name = "address")
    public String getAddress() {
        return address;
    }

    @Column (name = "home_phone")
    public String getHomePhone() {
        return homePhone;
    }

    @Column (name = "mobile_phone")
    public String getMobilePhone() {
        return mobilePhone;
    }

    @Column (name = "other_phone")
    public String getOtherPhone() {
        return otherPhone;
    }

    @ManyToOne
    @JoinColumn (name = "employee_type_id")
    public EmployeeType getType() {
        return type;
    }

    @Column (name = "career")
    public String getCareer() {
        return career;
    }

    @Column (name = "occupation")
    public String getOccupation() {
        return occupation;
    }

    @Column (name = "email")
    public String getEmail() {
        return email;
    }

    @Column (name = "active")
    public Boolean isActive() {
        return active;
    }

    @ManyToOne
    @JoinColumn(name = "user_id")
    public User getUser() {
        return user;
    }

    @Column(name = "old_id")
    public Long getOldId() {
        return oldId;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setHomePhone(String homePhone) {
        this.homePhone = homePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    public void setOtherPhone(String otherPhone) {
        this.otherPhone = otherPhone;
    }

    public void setType(EmployeeType type) {
        this.type = type;
    }

    public void setCareer(String career) {
        this.career = career;
    }

    public void setOccupation(String occupation) {
        this.occupation = occupation;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setOldId(Long oldId) {
        this.oldId = oldId;
    }
    
    @Override
    public String toString() {
        return firstName.concat(" ").concat(middleName).concat(" ").concat(lastName);
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (!(other instanceof Employee)) {
            return false;
        }
        Employee _i = (Employee) other;
        return id.equals(_i.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
